package com.ibuonline.b2b.entity;

import java.io.Serializable;

public class PaidKeywordRanking implements Serializable {

	private static final long serialVersionUID = -498253683596627789L;

	//fields
	private java.lang.Integer companyId;
	private java.lang.Integer keywordId;
	private java.lang.Long productId;
	private java.sql.Timestamp startDate;
	private java.sql.Timestamp endDate;
	private java.lang.Integer displayOrder;
	private java.lang.String status;

	//default constructor
	public PaidKeywordRanking() {
	}

	//constructor with arguments
	public PaidKeywordRanking(java.lang.Integer companyId, java.lang.Integer keywordId) {
		this.companyId = companyId;
		this.keywordId = keywordId;
	}

	//getter
	public java.lang.Integer getCompanyId() {
		return companyId;
	}
	public java.lang.Integer getKeywordId() {
		return keywordId;
	}
	public java.lang.Long getProductId() {
		return productId;
	}
	public java.sql.Timestamp getStartDate() {
		return startDate;
	}
	public java.sql.Timestamp getEndDate() {
		return endDate;
	}
	public java.lang.Integer getDisplayOrder() {
		return displayOrder;
	}
	public java.lang.String getStatus() {
		return status;
	}

	//setter
	public void setCompanyId(java.lang.Integer companyId) {
		this.companyId = companyId;
	}
	public void setKeywordId(java.lang.Integer keywordId) {
		this.keywordId = keywordId;
	}
	public void setProductId(java.lang.Long productId) {
		this.productId = productId;
	}
	public void setStartDate(java.sql.Timestamp startDate) {
		this.startDate = startDate;
	}
	public void setEndDate(java.sql.Timestamp endDate) {
		this.endDate = endDate;
	}
	public void setDisplayOrder(java.lang.Integer displayOrder) {
		this.displayOrder = displayOrder;
	}
	public void setStatus(java.lang.String status) {
		this.status = status;
	}

	//equals method
	public boolean equals(Object other) {
		if (this == other)
			return true;
		if (!(other instanceof PaidKeywordRanking))
			return false;

		final PaidKeywordRanking paidKeywordRanking = (PaidKeywordRanking)other;
		if (!this.companyId.equals(paidKeywordRanking.getCompanyId()) || 
			!this.keywordId.equals(paidKeywordRanking.getKeywordId()))
			return false;

		return true;
	}

	//hashCode method
	public int hashCode() {
		StringBuffer keys = new StringBuffer();
		keys.append(companyId).append(",");
		keys.append(keywordId).append(",");
		if (keys.length() > 0)
			keys.deleteCharAt(keys.length() - 1);
		return keys.toString().hashCode();
	}

	//toString method
	public String toString() {
		return new StringBuilder("PaidKeywordRanking[")
			.append("companyId=").append(companyId).append(", ")
			.append("keywordId=").append(keywordId).append(", ")
			.append("productId=").append(productId).append(", ")
			.append("startDate=").append(startDate).append(", ")
			.append("endDate=").append(endDate).append(", ")
			.append("displayOrder=").append(displayOrder).append(", ")
			.append("status=").append(status).append("]").toString();
	}

	///###
	private String companyName;
	private String keywordName;
	private String productName;
	public String getCompanyName() {
		return companyName;
	}
	public void setCompanyName(String companyName) {
		this.companyName = companyName;
	}
	public String getKeywordName() {
		return keywordName;
	}
	public void setKeywordName(String keywordName) {
		this.keywordName = keywordName;
	}

	public String getProductName() {
		return productName;
	}

	public void setProductName(String productName) {
		this.productName = productName;
	}
	
	public int getRemainDate(){
		if (this.endDate != null) {
			String today = new java.sql.Date(System.currentTimeMillis()).toString();
			long start = java.sql.Date.valueOf(today).getTime();
			long end = java.sql.Date.valueOf(endDate.toString().substring(0, 10)).getTime();
			return (int)((end - start)/(24*60*60*1000L)); 
		}
		return 0;
	}
}
